package com.demo2.servlet;

import com.sw.servlet.HttpServlet;
import com.sw.servlet.Request;
import com.sw.servlet.Response;
import com.sw.servlet.util.HttpProtocolUtil;

/**
 * @author sw
 * @project minicat
 * @description
 * @date 2020/4/30 12:47
 */
public class DemoTwoServlet extends HttpServlet {
    @Override
    public void doGet(Request request, Response response) {
        String str="<h1>DEMO 2 hello world Get</h1>";
        System.out.println("demo2"+request.getUrl());

        response.output(HttpProtocolUtil.getHttpHeader200(str.getBytes().length)+str);
    }

    @Override
    public void doPost(Request request, Response response) {
        String str="<h1>DEMO 2 hello world POST</h1>";
        System.out.println("demo2"+request.getUrl());
        response.output(HttpProtocolUtil.getHttpHeader200(str.getBytes().length)+str);

    }

    @Override
    public void init(String servletName) {
        System.out.println(servletName);
    }

    @Override
    public void destory() {

    }
}
